/**
 * Created with IntelliJ IDEA.
 * User: valeriykuchma
 * Date: 18.02.13
 * Time: 22:40
 * To change this template use File | Settings | File Templates.
 */

import enum_data.FormStatus;

import javax.swing.*;
import java.sql.*;

public class MainClass {
    public static void main(String[] args){

        //Установка Java Look and Feel (по умолчанию)
        try {
            UIManager.setLookAndFeel(
                    UIManager.getCrossPlatformLookAndFeelClassName());
//                    UIManager.getSystemLookAndFeelClassName());
        }
        catch (Exception e) { }

        //Set connection with data from configuration file
        TEDatabase db = new TEDatabase();
        db.getConnection();

        //region TEST
        Form_Tovar fu = null;
        fu = new Form_Tovar();
//        fu.pack();
        fu.setVisible(true);
        onClose();
        //endregion TEST

        //Открываем окно авторизации пользователя
        AuthForm authForm = new AuthForm();
        authForm.setVisible(true);

        if (Security.authorise){ //Авторизация - ОК
            FormMain formMain = new FormMain();
            formMain.setVisible(true);
        }
        else{
            onClose();
        }
    }

    private static void onClose(){
//        try {
//            TEDatabase.connection.close();
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
        System.exit(0);
    }
}
